namespace SmartSoft.ReportForms
{
    using SmartSoft;
    using SmartSoft.Controls;
    using SmartSoft.ADP;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormTBCT01Viewer : FormReportViewer
    {
        private IContainer components;
        private LabelControl lblMa_Kho;
        private LabelControl lblMa_Ts;
        private LabelControl lblNgay_Ct1;
        private LabelControl lblNgay_Ct2;
        private TextSearch txtMa_Kho;
        private TextSearch txtMa_Ts;
        private TextDate txtNgay_Ct1;
        private TextDate txtNgay_Ct2;
        private TextControl txtTen_Kho;
        private TextControl txtTen_Ts;

        public FormTBCT01Viewer()
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = AppInstance.StartWorkingDate;
            this.txtNgay_Ct2.Value = AppInstance.EndWorkingDate;
        }

        public FormTBCT01Viewer(object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_Ma_Kho, object ps_Ma_Ts, object pi_Loai_Tte)
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = pd_Ngay_Ct1;
            this.txtNgay_Ct2.Value = pd_Ngay_Ct2;
            this.txtMa_Ts.Value = ps_Ma_Ts;
            this.txtMa_Kho.Value = ps_Ma_Kho;
            this.txtTen_Ts.Value = this.txtMa_Ts.GetFieldData("Ten_Ts");
            this.txtTen_Kho.Value = this.txtMa_Kho.GetFieldData("Ten_Kho");
            this.OnMakeReport();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.txtTen_Ts = new SmartSoft.Controls.TextControl();
            this.txtMa_Ts = new SmartSoft.Controls.TextSearch();
            this.lblMa_Ts = new SmartSoft.Controls.LabelControl();
            this.txtNgay_Ct2 = new SmartSoft.Controls.TextDate();
            this.lblNgay_Ct2 = new SmartSoft.Controls.LabelControl();
            this.txtNgay_Ct1 = new SmartSoft.Controls.TextDate();
            this.lblNgay_Ct1 = new SmartSoft.Controls.LabelControl();
            this.txtTen_Kho = new SmartSoft.Controls.TextControl();
            this.txtMa_Kho = new SmartSoft.Controls.TextSearch();
            this.lblMa_Kho = new SmartSoft.Controls.LabelControl();
            this.rptContainer.Panel1.SuspendLayout();
            this.rptContainer.SuspendLayout();
            this.SuspendLayout();
            // 
            // rptContainer
            // 
            // 
            // rptContainer.Panel1
            // 
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Kho);
            this.rptContainer.Panel1.Controls.Add(this.txtMa_Kho);
            this.rptContainer.Panel1.Controls.Add(this.lblMa_Kho);
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Ts);
            this.rptContainer.Panel1.Controls.Add(this.txtMa_Ts);
            this.rptContainer.Panel1.Controls.Add(this.lblMa_Ts);
            this.rptContainer.Size = new System.Drawing.Size(794, 500);
            this.rptContainer.SplitterDistance = 68;
            // 
            // txtTen_Ts
            // 
            this.txtTen_Ts.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Ts.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Ts.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Ts.CheckTextSearched = false;
            this.txtTen_Ts.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Ts.Enabled = false;
            this.txtTen_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Ts.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Ts.Location = new System.Drawing.Point(214, 27);
            this.txtTen_Ts.Name = "txtTen_Ts";
            this.txtTen_Ts.OldValue = null;
            this.txtTen_Ts.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Ts.TabIndex = 5;
            this.txtTen_Ts.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Ts.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            // 
            // txtMa_Ts
            // 
            this.txtMa_Ts.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Ts.CheckTextSearched = false;
            this.txtMa_Ts.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Ts.FieldDisplay = "Ten_Ts";
            this.txtMa_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Ts.FoundIsValid = true;
            this.txtMa_Ts.Location = new System.Drawing.Point(108, 24);
            this.txtMa_Ts.MaxLength = 32;
            this.txtMa_Ts.Name = "txtMa_Ts";
            this.txtMa_Ts.OldValue = null;
            this.txtMa_Ts.Size = new System.Drawing.Size(100, 20);
            this.txtMa_Ts.TabIndex = 4;
            this.txtMa_Ts.TableName = "DMTS";
            this.txtMa_Ts.TextDisplay = this.txtTen_Ts;
            this.txtMa_Ts.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Ts.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            // 
            // lblMa_Ts
            // 
            this.lblMa_Ts.AutoSize = true;
            this.lblMa_Ts.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Ts.Location = new System.Drawing.Point(12, 27);
            this.lblMa_Ts.Name = "lblMa_Ts";
            this.lblMa_Ts.Size = new System.Drawing.Size(55, 14);
            this.lblMa_Ts.TabIndex = 87;
            this.lblMa_Ts.Text = "Mã tài sản";
            // 
            // txtNgay_Ct2
            // 
            this.txtNgay_Ct2.DateTimeFormat = SmartSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct2.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct2.Location = new System.Drawing.Point(316, 45);
            this.txtNgay_Ct2.Mask = "00/00/0000";
            this.txtNgay_Ct2.Name = "txtNgay_Ct2";
            this.txtNgay_Ct2.OldValue = null;
            this.txtNgay_Ct2.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct2.TabIndex = 7;
            // 
            // lblNgay_Ct2
            // 
            this.lblNgay_Ct2.AutoSize = true;
            this.lblNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct2.Location = new System.Drawing.Point(256, 48);
            this.lblNgay_Ct2.Name = "lblNgay_Ct2";
            this.lblNgay_Ct2.Size = new System.Drawing.Size(54, 14);
            this.lblNgay_Ct2.TabIndex = 97;
            this.lblNgay_Ct2.Text = "Đến ngày";
            // 
            // txtNgay_Ct1
            // 
            this.txtNgay_Ct1.DateTimeFormat = SmartSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct1.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct1.Location = new System.Drawing.Point(108, 45);
            this.txtNgay_Ct1.Mask = "00/00/0000";
            this.txtNgay_Ct1.Name = "txtNgay_Ct1";
            this.txtNgay_Ct1.OldValue = null;
            this.txtNgay_Ct1.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct1.TabIndex = 6;
            // 
            // lblNgay_Ct1
            // 
            this.lblNgay_Ct1.AutoSize = true;
            this.lblNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct1.Location = new System.Drawing.Point(12, 48);
            this.lblNgay_Ct1.Name = "lblNgay_Ct1";
            this.lblNgay_Ct1.Size = new System.Drawing.Size(47, 14);
            this.lblNgay_Ct1.TabIndex = 98;
            this.lblNgay_Ct1.Text = "Từ ngày";
            // 
            // txtTen_Kho
            // 
            this.txtTen_Kho.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Kho.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Kho.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Kho.CheckTextSearched = false;
            this.txtTen_Kho.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Kho.Enabled = false;
            this.txtTen_Kho.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Kho.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Kho.Location = new System.Drawing.Point(214, 6);
            this.txtTen_Kho.Name = "txtTen_Kho";
            this.txtTen_Kho.OldValue = null;
            this.txtTen_Kho.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Kho.TabIndex = 1;
            this.txtTen_Kho.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Kho.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            // 
            // txtMa_Kho
            // 
            this.txtMa_Kho.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Kho.CheckTextSearched = false;
            this.txtMa_Kho.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Kho.FieldDisplay = "Ten_Kho";
            this.txtMa_Kho.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Kho.FoundIsValid = true;
            this.txtMa_Kho.Location = new System.Drawing.Point(108, 3);
            this.txtMa_Kho.MaxLength = 32;
            this.txtMa_Kho.Name = "txtMa_Kho";
            this.txtMa_Kho.OldValue = null;
            this.txtMa_Kho.Size = new System.Drawing.Size(100, 20);
            this.txtMa_Kho.TabIndex = 0;
            this.txtMa_Kho.TableName = "DMKHO";
            this.txtMa_Kho.TextDisplay = this.txtTen_Kho;
            this.txtMa_Kho.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Kho.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            // 
            // lblMa_Kho
            // 
            this.lblMa_Kho.AutoSize = true;
            this.lblMa_Kho.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Kho.Location = new System.Drawing.Point(12, 6);
            this.lblMa_Kho.Name = "lblMa_Kho";
            this.lblMa_Kho.Size = new System.Drawing.Size(41, 14);
            this.lblMa_Kho.TabIndex = 108;
            this.lblMa_Kho.Text = "Mã kho";
            // 
            // FormTBCT01Viewer
            // 
            this.CheckDetailMost = true;
            this.ClientSize = new System.Drawing.Size(794, 532);
            this.Name = "FormTBCT01Viewer";
            this.rptContainer.Panel1.ResumeLayout(false);
            this.rptContainer.Panel1.PerformLayout();
            this.rptContainer.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnGenerateColumns()
        {
            object[][] objArray = new object[6][];
            object[] objArray2 = new object[4];
            objArray2[0] = "Ngay_Ct";
            objArray2[1] = "Ngày chứng từ";
            objArray2[2] = "D";
            objArray[0] = objArray2;
            object[] objArray3 = new object[4];
            objArray3[0] = "So_Ct";
            objArray3[1] = "Số hiệu";
            objArray3[2] = "C";
            objArray[1] = objArray3;
            object[] objArray4 = new object[4];
            objArray4[0] = "Dien_Giai";
            objArray4[1] = "Diễn giải";
            objArray4[2] = "C";
            objArray[2] = objArray4;
            objArray[3] = new object[] { "SL_Nhap", "Số lượng nhập", "N", AppInstance.TextNumericFormat.Quantity };
            objArray[4] = new object[] { "SL_Xuat", "Số lượng xuất", "N", AppInstance.TextNumericFormat.Quantity };
            objArray[5] = new object[] { "Ton_Cuoi", "Tồn cuối", "N", AppInstance.TextNumericFormat.Quantity };
            base.LocalColNames = objArray;
            base.OnGenerateColumns();
        }

        protected override void OnMakeReport()
        {
            AppInstance.StartWorkingDate = (DateTime) this.txtNgay_Ct1.Value;
            AppInstance.EndWorkingDate = (DateTime) this.txtNgay_Ct2.Value;
            base.LocalTable = new ReportDataAccess().TBCT01_Get(AppInstance.Subsidiaries, this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtMa_Kho.Value, this.txtMa_Ts.Value, AppInstance.DefLanguage);
            base.OnMakeReport();
        }

        protected override void OnSendParameters()
        {
            base.StimulReport["Ngay"] = "Từ ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct1.Value) + " đến ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct2.Value);
            if (string.IsNullOrEmpty(this.txtMa_Kho.Value.ToString()))
            {
                base.StimulReport["Kho"] = "";
            }
            else
            {
                base.StimulReport["Kho"] = string.Concat(new object[] { "Kho: ", this.txtTen_Kho.Value, " (", this.txtMa_Kho.Value, ")" });
            }
            if (string.IsNullOrEmpty(this.txtMa_Ts.Value.ToString()))
            {
                base.StimulReport["VatTu"] = "";
            }
            else
            {
                base.StimulReport["VatTu"] = string.Concat(new object[] { "Thiết bị: ", this.txtTen_Ts.Value, " (", this.txtMa_Ts.Value, ")" });
            }
        }
    }
}

